﻿@inject NavigationManager NavigationManager
@inject SessionStorage SessionStorage

<MudAppBar Elevation="2">
    <MudText Typo="Typo.h6">Egroo</MudText>
    <MudSpacer />
    <MudIconButton Icon="@Icons.Custom.Brands.GitHub"
                   Href="https://github.com/jihadkhawaja/Egroo"
                   Target="_blank" Rel="noopener noreferrer" />
    <MudIconButton Variant="Variant.Text"
                   Icon="@Icons.Material.Filled.Login"
                   Href="/signin" />
</MudAppBar>

<MudContainer MaxWidth="MaxWidth.Large" Class="my-16 pt-16">
    <MudText Typo="Typo.h3">Welcome to Egroo!</MudText>
    <MudText>Self-host chatting solution with cross-platform client application.</MudText>

    <MudStack Row Spacing="5" Class="mt-6">
        <MudButton Variant="Variant.Filled" Color="Color.Primary"
                   StartIcon="@Icons.Custom.Brands.GitHub"
                   Href="https://github.com/jihadkhawaja/Egroo"
                   Target="_blank" Rel="noopener noreferrer">
            GitHub Repository
        </MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Primary"
                   StartIcon="@Icons.Material.Filled.Login" Href="/signin">
            Sign In
        </MudButton>
    </MudStack>
</MudContainer>

@code{
    protected override void OnInitialized()
    {
        if (!string.IsNullOrEmpty(SessionStorage.Token)
            && SessionStorage.User is not null)
        {
            NavigationManager.NavigateTo("/channels");
        }
    }
}
